﻿using AnesSystem.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AnesSystem.ViewModels
{
    class QuxiangCountCtrlViewModel : BaseCountCtrlViewModel<QuxiangCountCtrlViewModel>
    {
        #region Variables
        #endregion

        #region Constructor
        public QuxiangCountCtrlViewModel()
        { }


        #endregion

        #region Properties


        public override void UpdateBaseCountModelList()
        {
            foreach (PatientLinkModel patientLinkModel in PatientLinkModelList)
            {



                bool onOff = true;
                
                foreach (BaseCountModel baseCountModel in BaseCountModelList)
                {
                    if (baseCountModel.Name.Equals(patientLinkModel.AnesthesiaRecord.Brqw))
                    {
                        onOff = false;
                        baseCountModel.Count++;
                    }
                }
                if (onOff)
                {
                    BaseCountModel baseCountModel = new BaseCountModel();
                    baseCountModel.Name = patientLinkModel.AnesthesiaRecord.Brqw;
                    baseCountModel.Count = 1;
                    BaseCountModelList.Add(baseCountModel);
                }
            }
        }


        #endregion

        #region 依赖属性

        #endregion

        #region Event

        #endregion

        #region Private Methods
        #endregion

        #region Public/Protected Methods
        public void UpdateDisPatientLinkModelList(BaseCountModel SelBaseCountModel)
        {
            if (SelBaseCountModel == null) return;
            if (SelBaseCountModel.Name != null)
            {
                DisPatientLinkModelList.Clear();
                //string _id = DataManager.Instance.AccountList.ToList().Where(O => O.TrueName.Equals(SelBaseCountModel.Name)).ToList().First().Id.ToString();
                DisPatientLinkModelList = PatientLinkModelList.Where(O => O.AnesthesiaRecord.Brqw == SelBaseCountModel.Name).ToList();
            }
        }

        #endregion

        #region EventHandlers

        #endregion
    }
}
